#pragma once

class UpdateData;
class WorldPacket;
namespace battle::object
{

    class ViewPoint;
    class Player;
    class WorldObject;
    class Camera
    {
        friend class ViewPoint;
    public:

        explicit Camera(Player* pl);
        ~Camera();

        WorldObject* GetBody() { return m_source; }
        Player* GetOwner() { return &m_owner; }

        // set camera's view to any worldobject
        // Note: this worldobject must be in same map, in same phase with camera's owner(player)
        // client supports only unit and dynamic objects as farsight objects
        void SetView(WorldObject* obj, bool update_far_sight_field = true);

        // set view to camera's owner
        void ResetView(bool update_far_sight_field = true);


        void UpdateVisibilityOf(WorldObject* obj, UpdateData& d, std::set<WorldObject*>& vis);
        void UpdateVisibilityOf(WorldObject* obj);
        void ReceivePacket(WorldPacket* data);

        // updates visibility of worldobjects around viewpoint for camera's owner
        void UpdateVisibilityForOwner();

    private:
        // called when viewpoint changes visibility state
        void Event_AddedToWorld();
        void Event_RemovedFromWorld();
        void Event_Moved();
        void Event_ViewPointVisibilityChanged();

        Player& m_owner;
        WorldObject* m_source = nullptr;

        void UpdateForCurrentViewPoint();

    public:
#if 0
        GridReference<Camera>& GetGridRef() { return m_gridRef; }
#endif
        bool isActiveObject() const { return false; }
    private:
#if 0
        GridReference<Camera> m_gridRef;
#endif
    };

}